import "./globals.css";
import "./reset.css";
import type { Metadata, Viewport } from "next";
import Favicon from "/public/favicon.ico";
import Script from "next/script";
import { isClient, isMobile, isProd } from "./utils";
import { CommonStoreProvider } from "@/src/providers/common-store-provider";
import { cookies, headers } from "next/headers";

export const viewport: Viewport = {
  initialScale: 1,
  userScalable: false,
  maximumScale: 1,
  minimumScale: 1,
  width: "device-width",
};
export const metadata: Metadata = {
  title: "百捷简历制作_简历模板下载_免费简历制作",
  description:
    "百捷简历是一款专业高效的求职简历制作工具，提供在线编辑功能，支持实时保存，确保您的信息安全。用户可以从丰富的模板库中选择适合自己的模板，一键生成精美简历，帮助您打造出色的求职简历，提升面试成功率",
  keywords:
    "简历，个人简历，在线制作简历，简历模板，简历下载，简历模板下载,简历制作,免费简历,word简历模板",
  formatDetection: { telephone: false },
  icons: [{ rel: "icon", url: Favicon.src }],
};

export default function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  const cookie = cookies().get("baijie_token");
  const headersList = headers();
  const userAgent = headersList.get("user-agent");
  const mobile = isMobile(userAgent);

  return (
    <html lang="en">
      <meta
        name="360-site-verification"
        content="c20ca9e891000f8e39a5e6e19ef5c1a6"
      />
      {isProd ? (
        <>
          <Script
            strategy="lazyOnload"
            src="https://hm.baidu.com/hm.js?325f3cea21fcfccc59926f211dc78677"
          ></Script>
          <Script
            strategy="lazyOnload"
            src="https://zz.bdstatic.com/linksubmit/push.js"
          ></Script>
        </>
      ) : null}
      <body>
        <CommonStoreProvider
          data={{ isMobile: mobile, isLogin: !!cookie?.value }}
        >
          {children}
        </CommonStoreProvider>
      </body>
    </html>
  );
}
